package org.ziwei.paipan.biao;

import org.ziwei.paipan.var.DiZhi;
import org.ziwei.paipan.var.Sex;
import org.ziwei.paipan.var.YinYang;

/**
 * 剩余杂曜表
 */
public class ZaXingBiao {
	/**
	 * 阳男阴女则命宫前六位安天伤，后六位安天使，即迁移宫前一宫安天使，后一宫安天伤
	 * 阴男阳女则命宫前六位安天使，后六位安天伤使，即迁移宫前一宫安天伤，后一宫安天使
	 * 根据出生时辰、出生月份、阴阳和性别，返回天伤所在宫支
	 * @param shiChen 出生时辰
	 * @param month 出生月份
	 * @param yinYang yinYang
	 * @param sex 性别
	 * @return DiZhi
	 */
	public static DiZhi anTianShang(DiZhi shiChen, int month, YinYang yinYang, Sex sex){
		int tianShang = 0;
		DiZhi mingGong = MingShenGongBiao.anMingGong(month, shiChen);
		if((yinYang == YinYang.YANG && sex == Sex.M) || (yinYang == YinYang.YIN && sex == Sex.F)){
			tianShang = (mingGong.ordinal() + 5) % 12;
		}else{
			tianShang = (mingGong.ordinal() + 7) % 12;
		}
		return DiZhi.values()[tianShang];
	}
	
	/**
	 * 根据出生时辰、出生月份、阴阳和性别，返回天使所在宫支
	 * @param shiChen 出生时辰
	 * @param month 出生月份
	 * @param yinYang yinYang
	 * @param sex 性别
	 * @return DiZhi
	 */
	public static DiZhi anTianShi(DiZhi shiChen, int month, YinYang yinYang, Sex sex){
		int tianShi = 0;
		DiZhi mingGong = MingShenGongBiao.anMingGong(month, shiChen);
		if((yinYang == YinYang.YANG && sex == Sex.M) || (yinYang == YinYang.YIN && sex == Sex.F)){
			tianShi = (mingGong.ordinal() + 7) % 12;
		}else{
			tianShi = (mingGong.ordinal() + 5) % 12;
		}
		return DiZhi.values()[tianShi];
	}

	/**
	 * 天才星由命宫起子年，顺数到本人生年之宫
	 * 根据出生时辰、月份和出生年地支，返回天才所在宫支
	 * @param shiChen 出生时辰
	 * @param month 出生月份
	 * @param diZhi 出生年地支
	 * @return DiZhi
	 */
	public static DiZhi anTianCai(DiZhi shiChen, int month, DiZhi diZhi){
		DiZhi mingGong = MingShenGongBiao.anMingGong(month, shiChen);
		return DiZhi.values()[(mingGong.ordinal() + diZhi.ordinal())%12];
	}
	
	/**
	 * 天寿星由身宫起子年，顺数到本人生年之宫
	 * 天寿星，重病危症，遇之都能化凶为吉，起死回生
	 * 根据出生时辰、月份和出生年地支，返回天寿所在宫支
	 * @param shiChen 出生时辰
	 * @param month 出生月份
	 * @param diZhi 出生年地支
	 * @return DiZhi
	 */
	public static DiZhi anTianShou(DiZhi shiChen, int month, DiZhi diZhi){
		DiZhi shenGong = MingShenGongBiao.anShenGong(month, shiChen);
		return DiZhi.values()[(shenGong.ordinal() + diZhi.ordinal())%12];
	}

}
